package com.ruoyi.StarStudio.Utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TDC_Coin {
    public static void main(String[] args) {
        List<Long[][]> fileData = ReadFileUtils.readFile("C:\\Users\\92149\\Desktop\\TDC\\0529处理数据\\formatData.txt");
        Map<Long,Long> deltaT_times = new HashMap<>();
        List<Long[][]> list = new ArrayList<>();
        long start = 0, end = 0;
        for (Long[][] data : fileData) {
            //具体算法
            if (data[0][1] == 1){
                start = data[0][0];
            } else if (data[0][1] == 2 && start != 0) {
                end = data[0][0];
            }else {
                continue;
            }
            long delta = end - start;
            deltaT_times.put(delta,deltaT_times.getOrDefault(delta,0L) + 1);
        }
        for (Long key : deltaT_times.keySet()) {
            Long[][] lineData = new Long[1][2];
            lineData[0][0] = key;
            lineData[0][1] = deltaT_times.get(key);
            list.add(lineData);
        }
        ReadFileUtils.writeFile(list,"C:\\Users\\92149\\Desktop\\TDC\\最终数据\\finalData.txt");
    }
}
